MAINT: replace more chunks of code with calls to existing functions