Javascript improvement