Refactored dynamic setter