fixed bugs with index