further refactoring of calculating revenue