Code for responding to user input