Refactor main.scala:main() to be cleaner and easier to read