Bug with array population