fixed some magic function errors