refact js version