maybe just
```scala
if (partition < 0) {
  partition = -partition -1
}
```