Added already connected check to prevent duplicate connections