A fix for case not categories are chosen.

The code did not care if the selected categories has any suitable value
or not.