refactor eval-magic