fixed some pattern matching