reworked add/edit action to be more generic