minor adjustments 03_04
04_03 optimized by substituting arrayList for array where possible