fix style, regactoring JS code