added digit algorithm to convert from array to int