using better pattern matching