Refactoring and adding stdin as source input