remove some double code in js