Added logic for input
Added redirection