changed from using window to using var