Fixed bug in beforeSave()