survival algorithm