Correcting gap insert logic.