fixed bugs + rest of the homework