Fixing a bug in connection