finished separateOverlappingContours() function