split up into multiple files
move some funcs out of main.c