Fixing bug in rescue logic