Fix index compare bug