added the rest of problem 4