refractoring code for setting autoset_owner_id, and use assertion when autoset_owner_id is True