f4 function merged