safer string conversion