Finished rankall function