added better error message for variable array index error