Bug fix: distance was not updating according to height