Fixed possible duplicate queries