Add the state monad implementation