Simplify the javascript