endwin needs to come first