s: issue #11, js refactoring