Fixed bug.

Was not using value passed to function, but rather variable outside of
function.