Refactored demand logic into a demand class.