groundwork for using state monad