solved by Scala