use string instead of ostringstream where possible for speed reasons