use pattern matching to access private record