initial draft of scala implementation