proper check for existence of a window object