kill algorithm written