Moved the query logic into a query method, so it is possible to call a query and process the results in other parts of your system.