Finished Scala conversion