beforeSave method added.