Added the distance calculation