Updated to use parameterized active patterns