Updated beforeDelete method