rearrenged query