Improved the speed of the queries