Completed the Query class and main method