calculation refactoring