start at refactor for state monad