Finished homework for week 4, just need to tidy code