Placed the redirection inside the function
merged