Add min and maximum argumet.

Min and maximum arguments - kind of similar to another pull request - but deals with edge cases a little better and doesn't use environment variables.