Refactoring

Created a utility.js file and cleaned up code