corrected contains and overlaps function