Add a variable to replace hard-coded upper bound

Haven't tested this since I don't have a large set of data.

See issue #242