working version.  Coods need sorted.  Too slow