Completed the r functions