one more fix to calculating distance