this is the main reason the program did not work befor. There is still a
major bug presetn which I can't find it now.
ready for testing