using if else to separate nested array elements
creating arrays with ArrayList