Refactored for input/output symmetry"