Updated code for user interaction