corrected category identification logic