[P5] Bug fix for segmentation fault error