problem 4, close to complete, returning incorrect result