Fixed index error, allowing weighting of minimum