BUG: fix NameError issue in GH2787

closes #2787