refactoring js pass 1
refactoring js pass 2