use globals instead of window