Fixed connection logic and removed debug, still might need more testing to confirm