Updated window code. Fixed the intial variable setting