updated getmaincategory function in category model