corrects off by one error