Correction to Ellers algorithm to prevent dead ends from happening