a nit style thing - the spark style usually do
```scala
taskOpt.foreach { task =>
  ...
}
```