Added index check