bug fix: renamed a variable name which was being reused in the same scope.