modify a bug in function findindex