I was trying to avoid having a pattern match chained with a pattern match inside a pattern match. But I'll simply use map + partial function, way better.