Refactored init.js file to be more readable