started refactoring of calculations