First go at a working version