Attempt to fix the queries function