optimize has_many relation edit logic