Rewritten in Scala