refining queries and output