minore refactoring in str() logic