Threw the input from console and stdInput to functions to make it more modular and readable