updated digits extraction, added modes support