organizing the queries