wrote initial code for problem 7