started monadic refactoring