Rewrote to use reduce and defmethod. Thanks Anderkent!