fixed array bounds bug