Fixed nonterminating condition and added more commentary