adding via point algorithm