More accurate and faster way to calculate the height of the head and foot