edited to better handle receiving c style string