Fix a possible out of index error