fixed minor off by one errors