Splitting up in smaller functions, to allow use in more varied ways.