product works for two ranges, has trouble with empty ranges and 3+ ranges