added weight support of functions