Refractoring the calculation code, starting to implement new rules