Handles user input