redesign the code, has better architecture.with the help of Zhisheng.