fix pattern category bug dropping last category