Fixed an error with the new query function