Added index check as well.