Use HashMap instead of looping through an ArrayList.