implemented RCS algorithm