simplify magic code