Problem passing array to a function