Fix incorrect variable name

Rewrote this function and missed one reference