Refactor condition in kill() function