fix for the case where the array is empty