Use global if window is not defined