Thanks for the reformat, one more thing: brackets for logic statements go on same line (`while( ... ) { ...`).  We only place them on new lines for the opening of a function body.  I see one other while like this below (if's are perfect).