Edited assignment 2 thanks to Charles' help