Fixed index generation bug