Rewrite in Scala
Whoops