migrate client query loop.