lib: toFunction