Fix improperly referenced variable

Fixes #2424