refactored calculations