Refactored get_input function to ternary operator