improve tab tool javascript