Finished HW3 Part 3, bit of a hack, but gets the job done