add scope isolating from possible conflicts and bugs also set window obj

add scope isolating from possible conflicts and bugs also set window obj to a faster reference to the window object