rlsquare algorithm!