added window, document, and undefined arguments to function