Added "document" to global variables