fixing duplicate logic in inputAddresses() and corresponding union