refine of script, file descriptor redirection