First draft
First (mostly) working version