changing erroneous reference to window to global