use in-house version of memmem