Scala implementation now working