updated js file with project 2 code to refactor