Update threshold code to specify number of bins rather than by.