Fix null element exception with toLowerCase()