Converted to Scala