finished optimized rankall-noloop.R