Worked on the last problem in the Assignment, quite tricky!