Code

Refactor user input handling into separate function