Added a method for getting the submitted queries. Moved duplicate code
to private method