updated with support for categories