solved the garbled bytes but result in segmentation fault