added onBeforeSave callback