Refactoring implementation of one_of