Check itemEx.type == 1 before the isInArray call, it's much faster.