simplify js  code