add Scala implementation