code cleanup
off by one error fix