code refactoring of js files