Scala Refactor homework