created fuctional implementation of rpn