Change datarange algorithm to fix log bug