Uses state monad transformer to do IO in dispatcher loop