simplify javascript