d38da13 more accurate range context calculation