fixed entity query bugs