Add a check whether the index exists instead of just dumping a PHP error. Still shouldn't happen though.