fix issue#2; 代码重构