Fix a bug when the window doesn't show up sometimes