detecting intersection of two rectangles