transfered js code to external .js file in public directory.