rewrote in c++ to take advantage of easier string handling/dynamic strings