fix some undefined variable errors