Fix out-of-range error when tabbing between last-first elements