minor changes in magic.cpp