Fixed dictionary index check