add fold support
add fold support for function