refactored application logic into external js file.