Extract out "in_polygon" function