Pass window and document as arguments => more minimified code