fixed most of the queries