Moved private Query function to a utility class.