change query logic