recursive function fillArray