modified problem 3

avoids monads