Refactored input-handling code out of main() and into separate functions