fix index comparison