updated get_string to avoid segmentation fault