First working (but incomplete) version