addition of refactoring calculation code