safe string handling