This looks like a very messy way to construct an object. Nested `if` `else` are hard to parse and an indication to me that a function is too big.