working on better connect function