not sure about using state monad here