MAINT: move a function into a more appropriate module