cleaned code and added get_window_name