improve IO with ostream operator overloading