Added support for array collection to hold items, refactored code