Change connection state checking logic.