fixing range calculation when min or max is negative