MAINT: move helper functions into a separate module