fixed scaling of contours and finding the best match