fix rank overflow