Improve line-to function to handle multiple points