quick fix for upper bound index check