Calculating vertical distance