Segmentation fault bug fix. use strncmp to flatten loop.