Fix error with index offsetting