stringstream refactoring