refactoring calc