finished part1 of problem3