fixed range calculation bug