fixed calculation ignoring minimum, now position is more accurate matching range, rather than ratio of max