serialization and better handling of connections