reorder state and pg monad transformers to have a global state