initial sort-of working version