Moved Query to the highest level