Hmm, this nested pattern matching is a bit confusing.