refactor - declared var's to functional scope.