Added half-match optimalization