fix error introduced through removal of magic_cast