cleaned up ‘halt’ logic