added reverse string in order to process the numbers correctly in order