implement beforeSave