Refactored calculate routine and passed all existing unit tests.