nearly everything is finished, can not read from txt. need to improve the algorithm