Fixing bugs in fillGaps (still buggy)