Add input handling to main