Simplified the monad code