Add function to redirect output