Used the more elegant strbuf API for string manipulation