restructured the summoning code