this is the first working version, more to be done