Refactoring to use magic method instead of too many implementations