fixed substring bug.