Nice catch! We should check the array is empty or not.