fixed problem3 code