Refactoring calculate