modify the code to incorperate window, but it has some issues because of window...