change window to $window