Fix crash if rank is undefined