finally fix off by one errors