JS restructure