Simplified some pattern matching