Added logic to save relation fields