First draft of a working version