improved some of the queries