TODO: RRR algorithm