constructed a state monad; still a bit confused