solved up to problem 5