Moved code in DecodeString to make it more efficient