a somewhat working first implementation