Fixed magic function handling