refactoring
moved code to separate js file
small updated