fixed array off by one error