Centralize the existing routines in a helper function