more efficient method as it only checks for transits when y is positive