added a check for potential result size before calling computeCarthesianProduct