Fix OutOfBoundException when list was empty.