fix mag runtime error