Modified getRandom function to work with categories with less than 4 products .