corrected Raouf's BUG on categories