refactor for Scala