Removed unused variables and use redirection