RAF algorithm implementation