worked on problem 3, needs revamping.