refactoring monads
more refactoring