Reduce code duplication in last commit.