better use of State monad