fixed off by one causing array bounds crash