Made combination function more stable for bad input.