JS restructure part1