Added z-axis calculation