refactored onDeath