fix small bug and add index