move modules to functions but keep old leafs