added a condition to retrieve courses assigned to visible categories