Fixing therank issue. Using the ordered one. TODO:changing the test comparison with is.na() check.