Improved version of user input function