implemented ori function