finished problem2 of homework 1
amend version