mostly working, value off by 1 err