iterate through all digits, conciser code