rpn refactoring