Refactor (Use *str instead of str[i]).