js restructure