moved some functions over from main.js, will update and clean up