An example on how to clean up Java code when handling collections