fix rank check