Added comments and a seperate js file