Refactor <digits> to make it more elegant