finished the array logic