added null pointer checks to string functions