modify based on Jianfeng’s comments
add comments for IndexOf()