Unexpected Error: document is not defined