Trying to solve problem3