You have to check if there are two elements in the array before trying to access them