using <sstream> for logic_error messages