first almost-working version