finished update_entity method