added apply_monad_deep function to recursively apply monads