adding error check for empty array in api response