fixed problem with window and document objects