off by one bugfix