fixed index bugs