fixed random function which previously errored out when only 1 problem in category