fix bug when initializing the window