Chnage global to window