add mutable state using monads