buffer matching fix-up

find a full match at first, after that find a best match