first half of the homework; had to correct for missing gem