first working version. Tests ok