Added polyline simplification function