monad code cleanup