format, add comments and log connect errors