Seemed to fix off-by-one error