calculations refactor