query refator