first somewhat working version