fixing an off by one error