correcting some bugs

code was working because of testing I was doing in the same session.
Correct variable names