isolated main func inner loops