cleaned-up and validated point-in-polygon functionality