Added new func to handle conection