js error testing for undefined variable (fixed)