move functions and form a better source tree structure