Completed p2 in Ruby