Fix out of bonds index error.