first attempt at problem 4, it does not work right