fixed bugs, including initializing empty arrays, correct as [[]]*N