initial draft of reference impl