restructure some js