first working version, needs refining :smile: