fix bug on wrapping around; off by one

Signed-off-by: Takeshi Banse <takebi@laafc.net>