fixed bug dereferencing empty array.