Move routing of last PEP items into new function

This doesn't change the behavior, but avoids some code duplication.