Coding the detectDeath method