Added safety checks in the entity object