add function factory