refactoring js looks ok