refactored magic method, tests.