Yep, I forgot it . Updated the code above to include (Pt.X<=R.right) and changed functiono to function

Thanks for the sanity check czar