fixed the queries