Add a detail:: function to package the index calculation; check k - min, not simply k.