Update: changed for loop to while in compare_string