fix add/edit func with relations