learn more from 9Z's solution, especially dealing with ArrayList