refactoring Main.scala