Reformatted Code
Fixed when the total number of items are calculated
removed debug messaged and a redundant line