Final version of rankall

working code