implement persistent connection logic