tested version, seems to be working OK (tested with only nitems=10, one of which failed the n range selection giving 9 gals total)
(#389)