Simplify javascript