loop changed to memchr