Refactored code design for readability & coherency