Scala Convert Method to Function