breaking code in string_parse out into functions