more reliable stream and string manipulations