Refactoring of calculation