did you know some of that code is already in main.js? may be able to consolidate.