cast magic to the code