first implementation of intersection removing