Bugfix: build next array
Improve error message