MAINT: merge two functions