refactor monads