Moved digit extraction code
Moved digit extraction code