Move connect code to seperate file and throw error on multiple connects