calc refactor