js refactored #1