replace provider function in an anonymous function into provider declaration