change factory to return function not connection
change factory to return function not connection