Fix bug in code. Window object should be accessed by using the variable @window