reusable code in Scala