Refactoring in ArrayList