fix bugs and add connection logic