more query logic