move code from AppDelegate to WindowController