Working version
Fixed index