Fixed Variable Scopes in Document Controller.