Fixed calculation error with double matches