js refucktoring