Fixed messed up connection logic