Refactor to loop through each expandedDigit