Fix previous-category check logic