Only loop through data if data is an array