state: fix the monad as Adam suggested