changed hand to use ArrayList instead of TreeSet