more variable renaming and reorganization
explanation of (0..9).each