For some reason this code does not append to an array but rather overwrites it, i am going nuts trying to figure out why!