- improved Scala implementation to be closer to C++/Java/JavaScript