pattern matching and static type now working