Fixing query event listeners