correct silly of-by-one errors