improved point in polygon algorithm