condensed code for rps.rb