first attempt at problem 5