Refactored to add function call, prompt for number, and error checking.