first attempt at problem 3. Late and tired so very poor attempt