Added ranking function for states