Moved string conversion to a template function