refactor some of jobs I wrote days ago, as I am learning scala.