Use correct var, this whole func needs cleaning up.