rearrange main.js in a way that doesnt give me the creeps