I think this would also be substantially improved by using `defaultValue` throughout as well, especially since it uses both `!== 'undefined'` and `=== 'undefined'` which seems particularly confusing.