Moved input handling to its own file