Fixed a small bug on the category code