small refactoring of FactorValue encoding