mediocre solution to packing gaps