for bug #194, refine code, remove the old duplicated code.
for bug #194, refine code, to 2.0.17