Added distance calculation