Solution to last digit problem