Hook up the query properly