use string[i] instead of string.substr(i)