refactoring to simplify MonadPrim use