a string to integer conversion function