Refactored to include functional elif.