Minor changes
Change the definition of R to use history instead of last node