first working version of covering algo