fixed beforeSave definition throwing a notice