Fix substring bug.