made some code easier to read by adding spaces between lines; commented so we know what f, g, and b mean in averageXS method