Nearly done with problem 1