improve outline fixing algorhitm