switch to monad implementation