updated the plane sweep algorithm