remove the assumption that "this === window"
check if window exists