off by one error fixed