code to remove middle points in lines