first working code of window opening