condensed seed and main loops into functions