Added RState.next() function