fixed halfO, implemented R