Improve performance by skipping loop as soon as first match is found.