Algorithm line can be a polygon part 1