fixing index error