Fixed indice bugs caused by the api change