refact js