first working version .. somewhat