`partition` as a separate function