Move javascript code to outer file
Refactoring