refix the index error