Adding type checking to fix a warning encountered when returned data was not an array.