broke portalExec into subfunctions for custom event loops