minor refactor to calculate_range method