added function factory example