fixed one bug. The whole program is runable.