restructuring of js