range calculation