moving master code to .js file