refactred #final_state_rank