Fixed variable scope.
Merge pull request #2888 from aanbar/develop

Fixed variable scope.