fix index check