fix bug when querying the name of an entity