Improve the grammar of the following text:
The time spend on the homework of those subjects should have been spent in the library.
The time spend spent on the homework for those subjects should have been spent in the library.