factor out all of the survival code