Update hid.c

rewritten the search routine