refactor rank to be data driven