Move stuff outside rps() function