Made connect function run in seperate thread, not safe and still basic