Improve memsearch func