fix index bugs

fix index bugs + test time