compute distance if not present