Match error is thrown only because you place the `if` within the `case` itself. I think a better way to write this is

```
.foreach { case (durationLimit, durationString) =>
  if (ms < durationLimit) {
    return durationString
  }
}