restructure main toxic loop