finished the second problem in the assignment 2