Added loop to support multiple sections; confirmed maths with real-world example