move parts of main js into modules