rewrote pattern matching to support values and labels (broken)