Fixing index error