modified function2