Refactor kill and revive process