Solving assignment 2