Changing JS structure. Adding JS console log statements. Optimizaing for testing