Trying to organize the JS file a bit for sanity's sake