JS restructuring for expansion