edited for problem 5