Remake counter-function for independent number of digits
Fix some functions according to the new counter-function