continuing to refactor and clean up the calculation and layout