first attempt at problem 1