finally solved the print redirecting problem