Fixing the out of bounds exception.