Completed p2 in Scala