fix custom spawn function