Fixed bug in rankall function