Fixed bug where the last query was not actually being run