check for empty list before accessing first element.