Further simplified the class and inner for loop.