replace IORef with MVar