improved intersection check