Fixed createQuery() method