further bug fixing of cal_connectn function