Re-factored code for js bundling and minifying