Fix undefined $entity_type variable