first basically working version