Scala in functional style