Changed the way the loop is processed.