better logic in rank detection 

(do not override rank if not detected anymore, 
but change the rank if it has changed)