Refactor also added the state of the connection.