use RWS monad to combine static/mutable state, less global vars