improve javascript code
new ui